Requires Scripting PRO
SFTPFile represents an opened remote file accessed through an SFTP session.
It provides low-level operations such as reading, writing, retrieving attributes, and closing the file.
Instances of this class are typically obtained through:
readonly isActive: booleanIndicates whether the file handle is still open.
true: The file is open and can be usedfalse: The file has been closed or is no longer validreadAttributes(): Promise<FileAttributes>Reads metadata attributes of the file.
An object containing file attributes:
read(options?: { from?: number, length?: number }): Promise<Data>Reads data from the file with optional offset and length.
from?: The byte offset to start reading from. Defaults to 0.length?: The number of bytes to read. Defaults to reading until the end of the file.Promise<Data> containing the read bytes.readAll(): Promise<Data>Reads the entire contents of the file.
Promise<Data> containing all file data.write(data: Data, at?: number): Promise<void>Writes data to the file.
data: The binary data to write.
at?: The byte offset at which to start writing.
If omitted, behavior depends on the flags used to open the file:
"append" will write at the end of the file."write" will write from offset 0 unless the implementation maintains a current offset.close(): Promise<void>Closes the file handle.
After closing, isActive becomes false, and no further reads or writes are allowed.